home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 001 / piblist.arc / DISPLAYS.PAS < prev    next >
Pascal/Delphi Source File  |  1985-03-28  |  7KB  |  172 lines

  1. (*---------------------------------------------------------------------------*)
  2. (*                Display_Screen -- Display formatted screen                 *)
  3. (*---------------------------------------------------------------------------*)
  4.  
  5. PROCEDURE Display_Screen;
  6.  
  7. (*---------------------------------------------------------------------------*)
  8. (*                                                                           *)
  9. (*     Routine:  Display_Screen                                              *)
  10. (*                                                                           *)
  11. (*     Purpose:  Displays formatted screen                                   *)
  12. (*                                                                           *)
  13. (*     Calling Sequence:                                                     *)
  14. (*                                                                           *)
  15. (*        Display_Screen;                                                    *)
  16. (*                                                                           *)
  17. (*     Calls:                                                                *)
  18. (*                                                                           *)
  19. (*        Read_Line                                                          *)
  20. (*        Format_Line                                                        *)
  21. (*        Move                                                               *)
  22. (*        Window                                                             *)
  23. (*        InsLine                                                            *)
  24. (*        DelLine                                                            *)
  25. (*        GoToXY                                                             *)
  26. (*                                                                           *)
  27. (*     Remarks:                                                              *)
  28. (*                                                                           *)
  29. (*        On entry Eod=FALSE if the viewing window contains at least one     *)
  30. (*        line.  In this case top points to the first line in the window.    *)
  31. (*        On exit bot points to the last Line in the window, and top_line    *)
  32. (*        is equal to the Line number of the top Line in the window.  If     *)
  33. (*        the viewing window extends beyond the end of the file then the     *)
  34. (*        extra Line <End of file> is displayed.                             *)
  35. (*                                                                           *)
  36. (*        On entry Eod=TRUE if the viewing window is beyond the end of the   *)
  37. (*        file. In this case top points to the last line in the buffer,      *)
  38. (*        which is the last line in the file.  Only the message              *)
  39. (*        <End of file> is displayed.  On exit bot=top and top_line is       *)
  40. (*        the line number of the last line in the file plus 1.               *)
  41. (*        The <END of file> message is considered in this case               *)
  42. (*        to be an "extra" line on the file with line number Max_line+1.     *)
  43. (*        This gives proper behavior on subsequent backwards line and screen *)
  44. (*        skipping commands.                                                 *)
  45. (*                                                                           *)
  46. (*        Note:  Requests for 1 line up or down scrolls are handled          *)
  47. (*               as special cases.                                           *)
  48. (*                                                                           *)
  49. (*---------------------------------------------------------------------------*)
  50.  
  51. VAR
  52.    n:      INTEGER;
  53.    LineNo: INTEGER;
  54.    ReDraw: BOOLEAN;
  55.  
  56. BEGIN  (* Display_Screen *)
  57.  
  58.    Window( 1 , 1 , 80 , 24 );
  59.  
  60.    bot    := top;
  61.    n      := Height;
  62.    LineNo := 0;
  63.    One_Up := One_Up AND ( Top^.Lnum <> 1 );
  64.  
  65.                                    (* Redraw is TRUE to redraw entire *)
  66.                                    (* screen.                         *)
  67.  
  68.    ReDraw := NOT ( One_Up OR One_Down );
  69.  
  70.    IF Eod THEN
  71.       top_line := Top^.Lnum + 1
  72.    ELSE
  73.       top_line := Top^.Lnum;
  74.  
  75.                                    (* Case one: scroll screen down 1 line *)
  76.    IF One_Up THEN
  77.       BEGIN
  78.          GoToXY( 1 , 1 );
  79.          InsLine;
  80.          Format_Line( Bot^.Txt, 1 );
  81.          Move( My_Screen, Real_Screen^, 160 );
  82.          WHILE ( n > 0 ) AND ( NOT Eod ) DO
  83.             BEGIN
  84.                LineNo := LineNo + 1;
  85.                n      := n - 1;
  86.                IF n > 0 THEN
  87.                   IF bot = last THEN
  88.                      BEGIN
  89.                         Read_Line;
  90.                         Eod := eof(f);
  91.                         bot := last;
  92.                      END
  93.                   ELSE
  94.                      bot := Bot^.next;
  95.             END;
  96.       END
  97.                                    (* Case 2: Scroll screen up 1 line *)
  98.    ELSE IF One_Down THEN
  99.       BEGIN
  100.          GoToXY( 1 , 1 );
  101.          DelLine;
  102.          WHILE ( n > 0 ) AND ( NOT Eod ) DO
  103.             BEGIN
  104.                LineNo := LineNo + 1;
  105.                n      := n - 1;
  106.                IF n > 0 THEN
  107.                   IF bot = last THEN
  108.                      BEGIN
  109.                         Read_Line;
  110.                         Eod := eof(f);
  111.                         bot := last;
  112.                      END
  113.                   ELSE
  114.                      bot := Bot^.next;
  115.             END;
  116.  
  117.          IF n <= 0 THEN
  118.             BEGIN
  119.                Format_Line( Bot^.Txt, LineNo );
  120.                GoToXY( 1 , LineNo );
  121.                Move( My_Screen[ ( LineNo - 1 ) * 160 + 1 ],
  122.                      Real_Screen^[ ( LineNo - 1 ) * 160 + 1 ], 160 );
  123.             END
  124.         ELSE
  125.            BEGIN
  126.               LineNo := LineNo + 1;
  127.               GoToXY( 1 , LineNo );
  128.               WRITE( '<End of File>' );
  129.               n := n - 1;
  130.            END;
  131.       END
  132.                                    (* Case 3:  Everything else *)
  133.    ELSE
  134.       BEGIN
  135.          WHILE ( n > 0 ) AND ( NOT Eod ) DO
  136.             BEGIN
  137.                LineNo := LineNo + 1;
  138.                Format_Line( Bot^.Txt, LineNo );
  139.                n := n - 1;
  140.                IF n > 0 THEN
  141.                   IF bot = last THEN
  142.                      BEGIN
  143.                         Read_Line;
  144.                         Eod := eof(f);
  145.                         bot := last
  146.                      END
  147.                   ELSE
  148.                      bot := Bot^.next;
  149.             END;
  150.  
  151.             IF n > 0 THEN
  152.                BEGIN
  153.                   LineNo := LineNo + 1;
  154.                   Format_Line( '<End of File>', LineNo );
  155.                   n := n - 1;
  156.                END;
  157.  
  158.             WHILE( n > 0 ) DO
  159.                BEGIN
  160.                   LineNo := LineNo + 1;
  161.                   Format_Line( ' ', LineNo );
  162.                   n := n - 1;
  163.                END;
  164.  
  165.                                    (* Update screen memory *)
  166.  
  167.             Move( My_Screen, Real_Screen^, Screen_Size );
  168.  
  169.       END;
  170.  
  171. END   (* Display_Screen  *);
  172.